package com.zbkj.service.model.front.vo.user;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.minidev.json.annotate.JsonIgnore;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;

@Data
@ApiModel
public class DateFundFlowVO {

    @ApiModelProperty(value = "日期", example = "06-30")
    private String date;

    @JsonIgnore
    private Integer intDate;

    @ApiModelProperty(value = "流水")
    private List<FundFlowVO> fundFlowList;

    public static DateFundFlowVO generate(LocalDate date, List<FundFlowVO> fundFlowList) {
        DateFundFlowVO dateFundFlowVO = new DateFundFlowVO();
        if (Objects.equals(LocalDate.now().getYear(), date.getYear())) {
            dateFundFlowVO.setDate(LocalDateTimeUtil.format(date, DateTimeFormatter.ofPattern("MM-dd")));
        } else {
            dateFundFlowVO.setDate(LocalDateTimeUtil.format(date, DatePattern.NORM_DATE_PATTERN));
        }
        dateFundFlowVO.setIntDate(Integer.valueOf(LocalDateTimeUtil.format(date, DatePattern.PURE_DATE_PATTERN)));
        dateFundFlowVO.setFundFlowList(fundFlowList);
        return dateFundFlowVO;
    }

}
